import 'package:flutter/material.dart';
import 'package:flutter_study/flutter/_15%E7%BB%BC%E5%90%88%E7%BB%83%E4%B9%A0/mixin%E5%BA%94%E7%94%A8/error_handle_mixin.dart';
import 'package:flutter_study/flutter/_15%E7%BB%BC%E5%90%88%E7%BB%83%E4%B9%A0/mixin%E5%BA%94%E7%94%A8/home_bloc.dart';

import 'base_page.dart';
import 'base_state.dart';
import 'basic_page_mixin.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: MixinScreen(),
    );
  }
}

class MixinScreen extends BasePage {
  @override
  State<StatefulWidget> createState() => _MixinScreenState();

  MixinScreen({Key key}) : super(key: key, bloc: HomeBloc());
}

class _MixinScreenState extends BaseState<MixinScreen>
    with BasicPageMixin, ErrorHandleMixin {
  @override
  Widget body() {
    return Center(
      child: Text("Test"),
    );
  }

  @override
  Widget fab() {
    return FloatingActionButton(
      onPressed: () {
        widget.bloc.errorSink.add("网络错误");
      },
      child: Icon(Icons.error),
    );
  }

  @override
  String screenName() => "测试Mixin";
}
